package com.hnust;

import com.hnust.config.YamlReader;
import com.hnust.util.URIInputStream;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

@SpringBootApplication
@EnableTransactionManagement
public class Main {
    public static void main(String[] args) throws IOException {
        File file=new File(System.getProperty("user.dir") +"/assets");
        if(!file.exists()){//如果文件夹不存在
            file.mkdir();//创建文件夹
        }
        file=new File(System.getProperty("user.dir") +"/assets/"+"example");
        if(!file.exists()){//如果文件夹不存在
            file.mkdir();//创建文件夹
        }
        file=new File(System.getProperty("user.dir") +"/assets/"+"upload");
        if(!file.exists()){//如果文件夹不存在
            file.mkdir();//创建文件夹
        }
        file=new File(System.getProperty("user.dir") +"/assets/"+"pictures");
        if(!file.exists()){//如果文件夹不存在
            file.mkdir();//创建文件夹
        }
        SpringApplication.run(Main.class);
        Files.copy(URIInputStream.getFileInputStream("http://"+ YamlReader.instance.getValueByKey("running.url") +":"+ YamlReader.instance.getValueByKey("server.port") + "/%E6%89%B9%E9%87%8F%E5%AF%BC%E5%85%A5%E9%A2%98%E7%9B%AE%E6%A8%A1%E6%9D%BF.docx"),new File(System.getProperty("user.dir") +"/assets/example/批量导入题目模板.docx").toPath());
        Files.copy(URIInputStream.getFileInputStream("http://"+ YamlReader.instance.getValueByKey("running.url") +":"+ YamlReader.instance.getValueByKey("server.port") + "/%E4%B8%93%E4%B8%9A%E6%AF%95%E4%B8%9A%E8%A6%81%E6%B1%82%E5%88%86%E8%A7%A3%E6%8C%87%E6%A0%87%E7%82%B9%E6%A8%A1%E6%9D%BF.docx"),new File(System.getProperty("user.dir") +"/assets/example/专业毕业要求分解指标点模板.docx").toPath());
        Files.copy(URIInputStream.getFileInputStream("http://"+ YamlReader.instance.getValueByKey("running.url") +":"+ YamlReader.instance.getValueByKey("server.port") + "/%E6%89%B9%E9%87%8F%E4%B8%8A%E4%BC%A0%E5%AD%A6%E7%94%9F%E6%A8%A1%E6%9D%BF.xlsx"),new File(System.getProperty("user.dir") +"/assets/example/批量上传学生模板.xlsx").toPath());
        Files.copy(URIInputStream.getFileInputStream("http://"+ YamlReader.instance.getValueByKey("running.url") +":"+ YamlReader.instance.getValueByKey("server.port") + "/%E6%89%B9%E9%87%8F%E4%B8%8A%E4%BC%A0%E6%95%99%E5%B8%88%E6%A8%A1%E6%9D%BF.xlsx"),new File(System.getProperty("user.dir") +"/assets/example/批量上传教师模板.xlsx").toPath());
        Files.copy(URIInputStream.getFileInputStream("http://"+ YamlReader.instance.getValueByKey("running.url") +":"+ YamlReader.instance.getValueByKey("server.port") + "/%E6%89%B9%E9%87%8F%E5%AF%BC%E5%85%A5%E8%AF%BE%E7%A8%8B%E7%9B%AE%E6%A0%87%E6%A8%A1%E6%9D%BF.docx"),new File(System.getProperty("user.dir") +"/assets/example/批量导入课程目标模板.docx").toPath());
    }
}
